/**
 *
 */
package com.lmx.persistence.service;

import java.math.BigDecimal;

import org.springframework.stereotype.Service;

import com.lmx.common.util.CommonUtil;
import com.lmx.persistence.service.common.BaseCrudServiceImpl;
import com.lmx.repoDomain.tmodel.Employee;
import com.lmx.repoDomain.tmodel.SalaryReportItem;
import com.lmx.repoDomain.tmodel.Tenant;

/**
 * 薪资月统计Service实现
 *
 * @author djs 2018年4月3日
 */
@Service(value = "salaryReportItemService")
public class SalaryReportItemServiceImpl extends BaseCrudServiceImpl<SalaryReportItem> implements
		SalaryReportItemService {

	@Override
	public SalaryReportItem receiveInitSalaryReportItem(Employee employee, Tenant tenant) {
		SalaryReportItem salaryReportItem = new SalaryReportItem();
		salaryReportItem.setName(employee.getName());// 员工姓名
		salaryReportItem.setIdcard(employee.getStaffCardCode());// 身份证号
		salaryReportItem.setStaffStatus(employee.getStaffStatus());// 状态
		salaryReportItem.setOnjobDate(employee.getToPositionDate());// 入职日期
		salaryReportItem.setRegularDate(employee.getRegularDate());// 转正日期
		if (employee.getDepartureDate() != null) {
			salaryReportItem.setLeaveDate(Integer.valueOf(employee.getDepartureDate()));// 离职日期
		}
		salaryReportItem.setProbationAmount(employee.getRegularAmount());// 试用期工资
		salaryReportItem.setRegularAmount(employee.getRegularAmount());// 转正工资
		salaryReportItem.setBaseAmount(employee.getSalaryPosition() == null ? BigDecimal.ZERO
				: employee.getSalaryPosition().getSalaryAmount());// 岗位工资
		salaryReportItem.setCreateDateTime(CommonUtil.getCurrTimes());// 创建时间
		salaryReportItem.setDelStatus((short) 0);// 有效标识默认0有效
		salaryReportItem.setOtherAmount(BigDecimal.ZERO);// 其它
		salaryReportItem.setTenant(tenant);
		return salaryReportItem;
	}
}
